/***************************************************************************************
* Copyright (c) 2014-2022 Zihao Yu, Nanjing University
*
* NEMU is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*          http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

#include "include/paddr.h"
#include "include/sim.h"
#include "stdio.h"
#include "include/reg.h"
const char *regs[] = {
  "$0", "ra", "sp", "gp", "tp", "t0", "t1", "t2",
  "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5",
  "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7",
  "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6"
};

void update_regs(){
    assert(dut);

    //cpu.pc = dut->rootp->

    for(int i=0;i<NR_GPRs;i++){
      cpu_state.gpr[i]  = dut->rootp->top__DOT__u_register_file__DOT__reg_file[i];
    }
}

void isa_reg_display() {
  int i;
  for(i=0;i<32;i++)
  {
    printf("%s: 0x%08x \n",regs[i],(word_t)dut->rootp->top__DOT__u_register_file__DOT__reg_file[i]);
  }
}



// word_t isa_reg_str2val(const char *s, bool *success) {
//   int i;
//   *success = true;
//   if (strcmp(s, regs[0]) == 0){
//     return gpr(0);
//   }
//   else if(strcmp(s+1,"pc")==0){ //跳过$
//       return cpu.pc;
//   }
//   for(i=0;i<32;i++)
//   {
//     if(strcmp(regs[i], s+1)==0) //跳过$
//     {
//       return gpr(i);
//     }
//   }
//   *success = false;
//   return -1;
// }
